<?php
    require_once '../../common/DBHelper.php';
    // 根据id把分类的信息修改
    $id = $_POST['id'];
    // 因为拼接sql语句时候是不需要id的，把id从$_POST里面删除
    $sql = "UPDATE posts set likes = likes + 1 WHERE id = {$id}";
    $conn = conn();
    $res = query($conn, $sql);
    close($conn);

    $response = ['code' => 0,'msg' => '操作失败'];
    
    if ($res) {
        $response['code'] = 1;
        $response['msg'] = '操作成功';
    }
    // 返回给前端
    echo json_encode($response, JSON_UNESCAPED_UNICODE);
